#include "datakit.h"
#include "tess/tess.h"
#include "TesselationEngine.hpp"
using namespace std;

int TessStatus = dtkTessellationNotStarted;

int GetTesselationStatus()
{
	return TessStatus;
}

DtkErrorStatus InitTesselation()
{
	DtkErrorStatus TesselationStatus = dtkErrorAllocation;

		//Initialization of tessellation library (used for PDF)
		TesselationStatus = (DtkErrorStatus)tess_InitTesselation("tess_tmp", 0.05);

		//Deactivating linear and angular tolerance => Angular tolerance of 10 degrees will be used
		tess_disableTolLinear(DTK_TRUE);
		tess_disableTolAngular(DTK_TRUE);

		//You can also use your own tessellation parameters :
		/*
		double LinearTol = 0.1;
		tess_set_linear(LinearTol);
		double AngularTol = 0.175; // angle in radian
		tess_set_angular(AngularTol); */

		if (TesselationStatus != dtkNoError)
		{
			cout << "Warning : Tesselation failed to start : " << dtkTypeError(TesselationStatus).c_str() << endl;
		}
	
	TessStatus = TesselationStatus;
    return TesselationStatus;
}

void EndTesselation()
{
	 tess_EndTesselation();
}

